data_count = int(input().strip())  
  
values = []
max_value = None  
max_index = 0  
  
for i in range(1, data_count + 1):  
    value = int(input().strip())  
    values.append(value)
      
    if max_value is None or value > max_value:  
        max_value = value  
        max_index = i  

print(max_value)

print(max_index)

for value in values[:(max_index - 1)][::-1]:
    print(value)
	
print(data_count)